package org.chenbingkang.modelmapper;

import org.modelmapper.AbstractConverter;
import org.modelmapper.Converter;
import org.modelmapper.ModelMapper;
import org.modelmapper.PropertyMap;
import org.modelmapper.spi.MappingContext;

import java.util.HashMap;
import java.util.Map;

public class Application {
    public static void main(String ... args){
        Name name=new Name();
        name.setFirstName("李");
        name.setLastName("四");
        Address address=new Address();
        address.setCity("长沙市");
        address.setStreet("岳麓大道");

        Customer customer=new Customer();
        customer.setName(name);

        Order order=new Order();
        order.setCustomer(customer);
        order.setBillingAddress(address);

        System.out.println(order);

        ModelMapper modelMapper = new ModelMapper();

        Map<String,Object> sourceMap=new HashMap<>();
        sourceMap.put("customerFirstName","李");
        sourceMap.put("customerLastName","四");
        sourceMap.put("billingStreet","岳麓大道");
        sourceMap.put("billingCity","长沙市");


        Map<String,Object> sourceMap3=new HashMap<>();
        sourceMap3.put("firstName","李");
        sourceMap3.put("lastName","四");
        Map<String,Object> sourceMap4=new HashMap<>();
        sourceMap4.put("street","岳麓大道");
        sourceMap4.put("city","长沙市");

        Map<String,Object> sourceMap2=new HashMap<>();
        sourceMap.put("customer",sourceMap3);
        sourceMap.put("billing",sourceMap4);


        OrderDTO orderDTO = modelMapper.map(sourceMap2, OrderDTO.class);
        System.out.println(orderDTO);

    }
}
